package com.liangli.thread.service.impl;

import com.liangli.thread.entity.Amazon;
import com.liangli.thread.mapper.AmazonMapper;
import com.liangli.thread.service.IAmazonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: liangli
 * Date: 2021/10/9 13:57
 * Description:
 */
@Service
public class AmazonServiceImpl implements IAmazonService {

    @Resource
    AmazonMapper amazonMapper;

    @Override
    public List<Amazon> search() {
        return amazonMapper.search();
    }

    @Override
    public void addBatch(List<Amazon> amazonList) {
        amazonMapper.addBatch(amazonList);
    }

    /**
     * 批量插入的线程池异步实现
     *
     * @param amazonList
     */
    @Override
    @Async
    public void addBatchExecutor(List<Amazon> amazonList) {
        amazonMapper.addBatch(amazonList);
    }
}
